#ifndef GPSMODULE_H_
#define GPSMODULE_H_

#include "..\System\F2806x_Device.h"
#include "UARTDriverB.h"

class GPSModule : public UARTDriverB
{
public:
	bool Initialize();
	void Update();
	void GetCoordinates(char* buffer);
	void GetFixInfo(char* buffer);
	void GetTime(char* buffer);
	float64 GetLatitude();
	float64 GetLongitude();
	float GetAltitude();
	int GetSatUsed();
	float GetVelX();
	float GetVelY();
	bool GetReceivedAutoreset(); // will auto reset after read
	
private:
	int RXBufPosition;
	char RXBuffer[201];

	// data
	char m_time[20];
	char m_latitude[20];
	char m_longitude[20];
	float64 m_Lat;
	float64 m_Long;
	int m_fixStatus;
	int m_satUsed;
	float m_alt;
	char m_NS;
	char m_EW;
	long m_MessageCount;
	long m_ErrorCount;

	float m_COG;
	float m_SOG;
	float m_VelX; // [m/s]
	float m_VelY; // [m/s]

	bool m_NewReceived;

private:
	int ParseCommand(char* input);
	unsigned char CalculateChecksum(char* str, int len);
	bool CheckChecksum(char* str);
	void ExecuteCommand(char* input, int size);
};

#endif /*GPSMODULE_H_*/
